package com.achen.topic;

import com.achen.util.RabbitMQUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;

/**
 * topic 动态路由
 * @author achen
 * @create 2020-05-10 23:51
 */
public class Provider {
    public static void main(String[] args) throws IOException {
        Connection connection = RabbitMQUtil.getConnection();
        Channel channel = connection.createChannel();
        String exchangeName = "topics";
        //交换机类型 ---> topic 动态路由
        channel.exchangeDeclare(exchangeName,"topic");
        String routingKey = "save.user.delete.save";
        channel.basicPublish(exchangeName,routingKey,null,("topic动态路由模型，routingKey ---> ["+routingKey+"]").getBytes());
        RabbitMQUtil.closeConnectionAndChannel(channel,connection);
    }
}
